﻿@model PagedList<RBS.Core.Model.D_Order>
@using RBS.Core.Extension
@using Webdiyer.WebControls.Mvc
@{
    ViewBag.Title = "我的饭局";
    Layout = "~/Views/Shared/_UserLayout.cshtml"; 
}
<script>
    $(function () {
        $("#btnDelete").click(function () {
            var f_str = "";
            $(".ltable :checkbox[id='chkId']").each(function () {
                if (this.checked && this.value != "undefined") {
                    f_str += this.value + ',';
                }
            });
            $.dialog.confirm("删除记录后不可恢复，您确定吗？", function () {
                var url = '@Url.Action("AdminUserDelete")?ids=' + f_str;
                $.ajax({
                    url: url,
                    type: "post",
                    dataType: 'json',
                    success: function (data) {
                        if (data.IsSuccess) {
                            $.dialog.alert(data.Msg);
                            loadPage(data.Data);
                        }
                        else {
                            //  $("#msgtip").text(data.Msg);
                            $.dialog.alert(data.Msg);
                            
                        }
                    }
                });
            });
            return false;
        });   
    });


    function IsParticipate(id, s) {
        
      //  alert(id + "," + s);
        if(s==2){
            $.dialog({
                id: 'qx', title: '拒绝原因', width: '710', height: '520', content: $("#jujue").html(), ok: function () {  
                    var msg = IsParticipate1(id, s, $("#msg").val());
                    //this.reload();
                    return false;
                }  
            }); 
        }
        else
         {
            IsParticipate1(id, s, "同意"); 
        }
    } 
    function IsParticipate1(id, s, remark) {
       var url = '@Url.Action("IsParticipate")';
        $.ajax({
            url: url,
            type: "post",
            dataType: 'json',
            data: {
                orderid: id,
                status: s,
                remark: remark 
            },
            success: function (result) {  
                $.dialog.alert(result.Msg);
                window.location.reload();
            }
        });
    }
</script> 
<div class="content-tab-wrap">
    <div id="floatHead" class="content-tab">
        <div class="content-tab-ul-wrap">
            <ul>
                <li><a href="@Url.Action("OrderList")"  >我组织的饭局</a></li>
                 <li><a href="@Url.Action("MyDinner")" class="selected">我收到的邀请</a></li>
            </ul>
        </div>
    </div>
</div>

 <div class="tbllist">
<!--列表-->
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="ltable" id="ltable">
    <tr>
        <th width="5%">序号</th>  
         <th align="left" width="20%">预定酒店</th>
        <th align="left">就餐日期</th> 
        
        <th align="left">邀请人</th> 
        <th width="22%">操作</th>
    </tr>
    @if (null != ViewData.Model)
    {
        var i = 0;
        foreach (var item in ViewData.Model)
        {
            i++;
            <tr> 
                <td align="center">
                  @i
                </td>
                <td align="left">
               
                          @Html.ActionLink(item.HotelName, "HotelImg", "Store", new { area = "", id = item.H_Id }, null)
                </td>
                <td align="left">
                    @Html.DisplayFor(modelItem => item.ReserveDate)&nbsp;@Html.DisplayFor(modelItem => item.ReserveTime)
                </td> 
                     <td align="left">
                    @(new RBS.Core.BLL.U_User().GetModelByCache(item.U_Id).U_Name)
                </td> 
                <td align="center">
                     
                    
                    @{ 
            if (DateTime.Parse(item.ReserveDate + " " + item.ReserveTime) > DateTime.Now)
            {

                switch (item.OrderState)
                {

                    case (int)RBS.Common.RBSEnums.OrderStatus.Ok:
                        List<RBS.Core.Model.D_Guest> guestModel = new RBS.Core.BLL.D_Guest().GetModelList("OrderId=" + item.Id + " and GuestId=" + @ViewBag.UserId + "");
                        if (guestModel != null)
                        {
                            var guest = guestModel[0];
                            if (guest.Status == 0)
                            {
                                if (DateTime.Parse(item.ReserveDate + " " + item.ReserveTime) > DateTime.Now)
                                { 
                                  
                                    <a href="javascript:;" onclick="IsParticipate(@item.Id,1)">[接受]</a> 
                                    <a href="javascript:;" onclick="IsParticipate(@item.Id,2)">[拒绝]</a>  }
                            }
                            else if (guest.Status == 1)
                            {
                                @Html.ActionLink("加菜", "SetCookBook", "Yd", new { area = "", id = item.H_Id, orderid = item.Id }, null)
                                @Html.Raw("[已接受邀请]")
                            }
                            else if (guest.Status == 2)
                            {
                                @Html.Raw("[已拒绝邀请]")
                            }
                        }  
                        break;
                    case (int)RBS.Common.RBSEnums.OrderStatus.Dining: 
                                 @*     @Html.ActionLink("[使用优惠卷]", "OrderDeed", new {id=item.Id,hid = item.H_Id }, null)     *@
                        //就餐
                        break;
                    case (int)RBS.Common.RBSEnums.OrderStatus.ToComment:
                                    @Html.ActionLink("[点评]", "Index", "Store", new { area = "", id = item.H_Id }, null)
                        break;

                }
                
            }       
                       @Html.ActionLink("[详情]", "Detail", "Store", new { area = "", id = item.H_Id, orderid = item.Id }, null)    
                        
                        
                        
                        
                         

                    
                    }  
                </td>
            </tr>
        }
    }
</table></div>
<!--/列表-->
<!--内容底部-->
<div class="line20">
</div>

<div class="pagelist">
    <div class="l-btns">
        <span>显示</span> <span>10 条/页</span><span>共 @Model.TotalPageCount 页 @Model.TotalItemCount 条记录，当前为第 @Model.CurrentPageIndex 页</span>
    </div>
    @Html.Pager(Model, new PagerOptions { PageIndexParameterName = "id", ShowPageIndexBox = true, PageIndexBoxType = PageIndexBoxType.DropDownList, ShowGoButton = false, CurrentPagerItemWrapperFormatString = "<span class=\"current\">{0}</span>" }, new { id = "PageContent", @class = "default" })
    @section Scripts{@{Html.RegisterMvcPagerScriptResource();}}
</div>


<div  id="jujue" style="display: none" class="tab-content"> 
    <dl> 
        <dd>           
            @Html.TextArea("msg", null, 3, 30, null)
        </dd> 
    </dl> 
 </div>
 
<!--/内容底部-->


